import { addProj, delProj, findAllProj, findProj, updateProj } from '@renderer/apis/projAPI'
import { ref } from 'vue'

export default () => {
  const projs = ref<projModel[]>([])
  const proj = ref<projModel>()

  const add = async (data: any) => {
    return await addProj(data)
  }

  const all = async () => {
    const { data } = (await findAllProj()) as any
    projs.value = data
  }
  const find = async (id: number) => {
    const { data } = (await findProj(id)) as any
    proj.value = data
  }

  const del = async (id: number) => {
    await delProj(id)
  }

  const update = async (id: number, data: any) => {
    await updateProj(id, data)
  }

  return { add, all, find, del, update, projs, proj }
}
